home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / k3bcdparanoialib.h < prev    next >
Encoding:
C/C++ Source or Header  |  2008-05-27  |  3.9 KB  |  162 lines

  1. /* 
  2.  *
  3.  * $Id: k3bcdparanoialib.h 619556 2007-01-03 17:38:12Z trueg $
  4.  * Copyright (C) 2003 Sebastian Trueg <trueg@k3b.org>
  5.  *
  6.  * This file is part of the K3b project.
  7.  * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
  8.  *
  9.  * This program is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2 of the License, or
  12.  * (at your option) any later version.
  13.  * See the file "COPYING" for the exact licensing terms.
  14.  */
  15.  
  16.  
  17. #ifndef K3B_CDPARANOIA_LIB_H
  18. #define K3B_CDPARANOIA_LIB_H
  19.  
  20. // from cdda_interface.h
  21. #define CD_FRAMESIZE_RAW 2352
  22.  
  23.  
  24. #include <qstring.h>
  25.  
  26. #include <sys/types.h>
  27. #include "k3b_export.h"
  28.  
  29. namespace K3bDevice {
  30.   class Device;
  31.   class Toc;
  32. }
  33.  
  34.  
  35. /**
  36.  * K3bCdparanoiaLib is a convenience wrapper around libcdda_interface
  37.  * and libcdda_paranoia.
  38.  *
  39.  * It uses four paranoia levels 0-3 which can be set via setParanoiaMode
  40.  * and are used the same way as in cdrdao:
  41.  * \li 0: No checking, data is copied directly from the drive.
  42.  * \li 1: Perform overlapped reading to avoid jitter.
  43.  * \li 2: Like 1 but with additional checks of the read audio data.
  44.  * \li 3: Like 2 but with additional scratch detection and repair.
  45.  *
  46.  * K3bCdparanoiaLib is based on a shared data approach which makes sure
  47.  * that each device can only be opened once. This is necessary since 
  48.  * libcdda_interface opens the device exclusively on most distributions.
  49.  *
  50.  * However, it is perfectly possible to have two instances of K3bCdparanoiaLib
  51.  * accessing the same device at the same time. K3bCdparanoiaLib will take care
  52.  * of the syncing and seeking issues automatically.
  53.  *
  54.  * K3bCdparanoiaLib is thread-safe.
  55.  *
  56.  * Usage:
  57.  * <pre>
  58.  * K3bCdparanoiaLib lib;
  59.  * lib.initParanoia( mydevice );
  60.  * lib.initReading( tracknumber );
  61.  * while( char* data = lib.read() )
  62.  *   dosomethingcoolwithdata( data );
  63.  * </pre>
  64.  */
  65. class LIBK3B_EXPORT K3bCdparanoiaLib
  66. {
  67.  public:
  68.   ~K3bCdparanoiaLib();
  69.  
  70.   /** default: 1 */
  71.   void setParanoiaMode( int );
  72.   void setNeverSkip( bool b );
  73.  
  74.   /** default: 5 */
  75.   void setMaxRetries( int );
  76.  
  77.   /**
  78.    * This will read the Toc and initialize some stuff.
  79.    * It will also call paranoiaInit( const QString& )
  80.    */
  81.   bool initParanoia( K3bDevice::Device* dev );
  82.  
  83.   /**
  84.    * Use for faster initialization without reading the toc
  85.    */
  86.   bool initParanoia( K3bDevice::Device* dev, const K3bDevice::Toc& );
  87.  
  88.   void close();
  89.  
  90.   /**
  91.    * Call this after initParanoia to set the data to rip.
  92.    *
  93.    * Rip all audio tracks.
  94.    */
  95.   bool initReading();
  96.  
  97.   /**
  98.    * Call this after initParanoia to set the data to rip.
  99.    */
  100.   bool initReading( unsigned int track );
  101.  
  102.   /**
  103.    * Call this after initParanoia to set the data to rip.
  104.    */
  105.   bool initReading( long startSector, long endSector );
  106.  
  107.   /**
  108.    * Read data.
  109.    * \param statusCode If not 0 will be set.
  110.    * \param track the tracknumer the data belongs to
  111.    *
  112.    * This method takes care of swapping the byte-order depending on the
  113.    * machine type.
  114.    *
  115.    * \return The read sector data or 0 if all data within the specified range
  116.    *         has been read or an error has occured.
  117.    */
  118.   char* read( int* statusCode = 0, unsigned int* track = 0, bool littleEndian = true );
  119.  
  120.   /**
  121.    * This only is valid after a call to read()
  122.    */
  123.   int status() const;
  124.  
  125.   enum Status {
  126.     S_OK,
  127.     S_ERROR
  128.     // to be extended with Jitter and stuff...
  129.   };
  130.  
  131.   /**
  132.    * Only valid after a call to initParanoia()
  133.    */
  134.   const K3bDevice::Toc& toc() const;
  135.  
  136.   long rippedDataLength() const;
  137.  
  138.   /**
  139.    * returns 0 if the cdparanoialib could not
  140.    * be found on the system.
  141.    * Otherwise you have to take care of
  142.    * deleting.
  143.    */
  144.   static K3bCdparanoiaLib* create();
  145.  
  146.  private:
  147.   void cleanup();
  148.  
  149.   K3bCdparanoiaLib();
  150.   bool load();
  151.  
  152.   class Private;
  153.   Private* d;
  154.  
  155.   static void* s_libInterface;
  156.   static void* s_libParanoia;
  157.   static int s_counter;
  158. };
  159.  
  160.  
  161. #endif
  162.